<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Users</title>
    <link rel="stylesheet" th:href="@{/css/style.css}" />
</head>
<body>
<header>
    <div class="container">
        <div id="branding">
            <h1>Spring Boot User Management</h1>
        </div>
        <nav>
            <ul>
                <li><a th:href="@{/}">主页123</a></li>
                <li><a th:href="@{/books}">图书</a></li>
                <li class="current"><a th:href="@{/users}">用户</a></li>
                <li><a th:href="@{/logout}">退出</a></li>
            </ul>
        </nav>
    </div>
</header>
<div class="container">
    <h1>用户</h1>
    <table>
        <thead>
        <tr>
            <th>ID</th>
            <th>用户名</th>
            <th>邮箱</th>
            <th>编辑</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="user : ${users}">
            <td th:text="${user.id}">ID</td>
            <td>
                <div th:if="${user.avatarPath}">
                    <img th:src="@{${user.avatarPath}}" alt="头像" width="50" height="50" />
                </div>
                <div th:unless="${user.avatarPath}">
                    <span>无头像</span>
                </div>
            </td>
            <td th:text="${user.username}">用户名</td>
            <td th:text="${user.email}">邮箱</td>
            <td th:text="${user.role}">角色</td>
            <td>
                <a th:href="@{/users/edit/{id}(id=${user.id})}">编辑</a>
                <a th:href="@{/user/delete/{id}(id=${user.id})}"
                   onclick="return confirm('确定要删除这个用户吗?')">删除</a>
            </td>
        </tr>


        </tbody>
    </table>
</div>
</body>
</html>